package controller

import (
	"mini-app/internal/app/admin/service"

	"192.168.1.75/go-pkg/response"
	"github.com/gin-gonic/gin"
	"github.com/gin-gonic/gin/binding"
)

type User struct{}

func (User) List(c *gin.Context) {
	var params struct {
		StartTime int64  `json:"start_time"` // 注册时间 开始
		EndTime   int64  `json:"end_time"`   // 注册时间 结束
		NickName  string `json:"nick_name"`  // 会员昵称
		Phone     string `json:"phone"`      // 手机号码
		Page      int    `json:"page"`
		Limit     int    `json:"limit"`
		ID        string `json:"id"`
	}
	c.ShouldBindBodyWith(&params, binding.JSON)

	list, total, err := service.User{}.List(c.Request.Context(), params.ID, params.StartTime,
		params.EndTime, params.NickName, params.Phone, params.Page, params.Limit)
	response.JSON(c, gin.H{
		"total": total,
		"list":  list,
	}, err)
}
